var event = {
    clientListen : [],
    listen : function(key,fn){
        if(!this.clientListen[key]){
            this.clientListen[key] = [];
        }
        this.clientListen[key].push(fn);
    },
    trigger : function(){
        var key = Array.prototype.shift.call(arguments),
            fns = this.clientListen[key];
        if(!fns || fns.length === 0){
            return false;
        }
        for(var i=0,fn;fn=fns[i++];){
            fn.apply(this,arguments);//arguments 是 trigger 时带上的参数
        }
    },
    remove :function(key,fn){
        var fns = this.clientListen[key];
        if(!fns){
            return false;
        }
        if(!fn){
            fns &&(fns.length = 0);
        }else{
            for( var l = fns.length - 1; l >=0; l--)
            {
                let _fn = fns[l];
                if(_fn === fn){
                    fns.splice(l,1)
                }
            }
        }
    }
}
 
var installEvent = function( obj ){ 
    for ( var i in event ){ 
         obj[ i ] = event[ i ]; 
    } 
} 
